package com.example.merchant.service;

import com.example.merchant.entity.Customer;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Objects;

/**
 * 用户服务
 */
@Service
public class UserService {

    // 调用 MockDatabase 中的对应静态方法，查询所有性别为“男”的顾客列表
    public ArrayList<Customer> manCustomer(){
        ArrayList<Customer> manCustomerList = new ArrayList<>();
        for (int x = 0; x<MockDatabase.customerList().size(); x++){
            //Customer cus = MockDatabase.customerList().get(x);
            if(Objects.equals(MockDatabase.customerList().get(x).getSex(), "男")){
                manCustomerList.add(MockDatabase.customerList().get(x));
            }
        }
        return manCustomerList;

    }

    // 调用 MockDatabase 中的对应静态方法，查询所有年龄>18的顾客列表
   public ArrayList<Customer> customer18YearsOld() {
       ArrayList<Customer> customerList = new ArrayList<>();
       for (int x = 0; x < MockDatabase.customerList().size(); x++) {
           //Customer cus = MockDatabase.customerList().get(x);
           if (MockDatabase.customerList().get(x).getAge() > 18) {

               customerList.add(MockDatabase.customerList().get(x));

           }
       }
       return customerList;

   }

}
